<template>
	<view>
		<view class="detailItem flex align-center justify-between" v-for="i in list">
			<image v-if="i.log_type == 1" class="wicon" src="/static/image/WB/in.png"></image>
			<image v-else class="wicon" src="/static/image/WB/out.png"></image>
			<view style="width: 570upx;">
				<view class="flex align-center justify-between">
					<text style="font-size: 28upx;font-weight: bold;">{{type_text[i.source_type]}}</text>
					<text v-if="i.log_type == 1" style="font-size: 28upx;font-weight: bold;color:#63BE72;">{{i.note}}</text>
					<text v-else style="font-size: 28upx;font-weight: bold;color:#ff6588;">{{i.note}}</text>
				</view>
				<view class="flex align-center justify-between" style="font-size: 22upx;color: #aaa;margin-top: 10upx;">
					<text>{{i.create_time}}</text>
					<view>{{i.bonus_from}}</view>
				</view>
			</view>
		</view>
		<view class="hasmore">{{hasmore?'加载中':'没有更多了'}}</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list:[],
				page:1,
				page_size:10,
				hasmore:true,
			}
		},
		onLoad(op){
			this.type = op.type
			uni.setNavigationBarTitle({
				title:this.type==1?'余额明细':'美试券明细'
			})
			this.loadList()
		},
		onReachBottom(){
			if(this.hasmore){
				this.loadList()
			}
		},
		methods:{
			loadList(){
				this.$request({
					url: this.$api.wallet.balance_log,
					method:'post',
					data: {
						page:this.page,
						limit:this.page_size,
						b_type:this.type
					}
				}).then(res => {
					if (res.code == 0) {
						this.page ++
						this.type_text = res.type_text
						this.hasmore = res.data.length == this.page_size
						this.list = this.list.concat(res.data)
					}
				}).catch(res => {})
			},
		}
	}
</script>

<style scoped>
	.detailItem{
		width: 700upx;
		margin: 20upx auto 0;
		padding: 20upx;
		background: #fff;
		border-radius: 10upx;
	}
	.wicon{
		width: 70upx;
		height: 70upx;
	}
	.coupontext{
		height: 180upx;
		margin-left:140upx;
		color: #fff;
	}
</style>
